package com.ibuonline.b2b.entity;

import java.io.Serializable;

import com.ibuonline.b2b.common.SysCache;

public class ShopBannerCategory implements Serializable {

	private static final long serialVersionUID = 75845798587423444L;

	//fields
	private java.lang.Integer bannerId;
	private java.lang.Integer catId;

	//default constructor
	public ShopBannerCategory() {
	}

	//constructor with arguments
	public ShopBannerCategory(java.lang.Integer bannerId, java.lang.Integer catId) {
		this.bannerId = bannerId;
		this.catId = catId;
	}

	//getter
	public java.lang.Integer getBannerId() {
		return bannerId;
	}
	public java.lang.Integer getCatId() {
		return catId;
	}

	//setter
	public void setBannerId(java.lang.Integer bannerId) {
		this.bannerId = bannerId;
	}
	public void setCatId(java.lang.Integer catId) {
		this.catId = catId;
	}

	//equals method
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (!(other instanceof ShopBannerCategory))
			return false;

		final ShopBannerCategory shopBannerCategory = (ShopBannerCategory)other;
		if (!this.bannerId.equals(shopBannerCategory.getBannerId()) || 
			!this.catId.equals(shopBannerCategory.getCatId()))
			return false;

		return true;
	}

	//hashCode method
	public int hashCode() {
		StringBuffer keys = new StringBuffer();
		keys.append(bannerId).append(",");
		keys.append(catId).append(",");
		if (keys.length() > 0)
			keys.deleteCharAt(keys.length() - 1);
		return keys.toString().hashCode();
	}

	//toString method
	public String toString() {
		return new StringBuilder("ShopBannerCategory[")
			.append("bannerId=").append(bannerId).append(", ")
			.append("catId=").append(catId).append("]").toString();
	}
	
	public String getCatName() {
		ProdCategory prodCat = SysCache.getCategory(catId);
		if(prodCat != null) {
			return prodCat.getName();
		} else {
			return null;
		}
	}
}